import util


def get_port_id(camera_id):
    '''
    根据传入的摄像头id获取相应的端口号及其对应的索引
    '''
    port = None
    camera_index = None
    port_list = ['5001', '5002', '5003', '5004', '5005', '5031', '5032', '5033', '5034', '5035']

    for i in range(len(port_list)):
        camera_jsonList = util.get_camera_list(port_list[i])  # 端口对应的摄像头信息
        for m in range(len(camera_jsonList)):
            if camera_id == camera_jsonList[m]['camera_id']:
                port = port_list[i]
                camera_index = m
            else:
                continue

    return port, camera_index



if __name__ == '__main__':
    print(get_port_id(51)[1])
